﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MDL;
using DAL;

namespace BLL
{
    public class BLL_ConsumerBill
    {
        /// <summary>
        /// 获取当日最新账单编号
        /// </summary>
        /// <returns>最新账单编号</returns>
        public static string GetMaxCBID()
        {
            string str = DAL_ConsumerBill.GetMaxCBID();
            return str.Length <= 0 ? "ZD" + DateTime.Now.ToString("yyyyMMdd") + "0001" : "ZD" + DateTime.Now.ToString("yyyyMMdd") + (int.Parse(str.Substring(str.Length - 4, 4)) + 1).ToString().PadLeft(4, '0');
        }
        /// <summary>
        /// 右键修改状态为可用时改消费为结账
        /// </summary>
        /// <param name="id">餐台ID</param>
        /// <param name="CBID">账单号</param>
        /// <returns>受影响的行数</returns>
        public static int UpdateZT(int id, string CBID)
        {
            return DAL_ConsumerBill.UpdateZT(id,CBID);
        }
        /// <summary>
        /// 顾客开单的方法
        /// </summary>
        /// <param name="cb">开单信息</param>
        /// <returns>受影响的行数</returns>
        public static int AddConsumerBill(ConsumerBill cb)
        {
            return DAL_ConsumerBill.AddConsumerBill(cb);
        }
        /// <summary>
        /// 根据餐桌ID获取其当前账单编号
        /// </summary>
        /// <param name="TableID">餐桌ID</param>
        /// <returns>账单编号</returns>
        public static string GetMaxCBID(int TableID)
        {
            return DAL_ConsumerBill.GetMaxCBID(TableID);
        }
        /// <summary>
        /// 根据餐桌ID查询开单时间
        /// </summary>
        /// <param name="TableID">餐桌ID</param>
        /// <returns>开单时间</returns>
        public static object GetStateTime(int TableID)
        {
            return DAL_ConsumerBill.GetStateTime(TableID);
        }
        /// <summary>
        /// 查询最早开单时间
        /// </summary>
        /// <returns></returns>
        public static Object SelectMinTime()
        {
            return DAL_ConsumerBill.SelectMinTime();
        }
        /// <summary>
        /// 查询账单信息
        /// </summary>
        /// <param name="ktime">开单时间</param>
        /// <param name="jtime">结账时间</param>
        /// <param name="Rid">收款人</param>
        /// <param name="Tid">餐台ID</param>
        /// <returns>账单信息</returns>
        public static List<ConsumerBill> SelectInfo(string ktime, string jtime, int Rid, string Tid)
        {
            return DAL_ConsumerBill.SelectInfo(ktime,jtime,Rid,Tid);
        }
        /// <summary>
        /// 会员结账的方法
        /// </summary>
        /// <param name="cb">账单信息</param>
        /// <returns></returns>
        public static int EndConsumerBillVip(ConsumerBill cb)
        {
            return DAL_ConsumerBill.EndConsumerBillVip(cb);
        }
        /// <summary>
        ///普通结账的方法
        /// </summary>
        /// <param name="cb">账单信息</param>
        /// <returns></returns>
        public static int EndConsumerBillPt(ConsumerBill cb)
        {
            return DAL_ConsumerBill.EndConsumerBillPt(cb);
        }
    }
}
